# Contributor: André Klitzing <aklitzing@gmail.com>
# Maintainer: André Klitzing <aklitzing@gmail.com>
pkgname=rippled
pkgver=1.9.1
pkgrel=2
pkgdesc="Blockchain daemon implementing the Ripple Consensus Ledger"
options="net !check" # FIXME: 1 failure, rippled testsuite doesn't tell which one it is
url="https://ripple.com/"
# needs 64bit, build fails on s390x and ppc64le
arch="aarch64 x86_64"
license="ISC"
makedepends="
	boost-dev
	c-ares-dev
	cmake
	grpc-dev
	libarchive-dev
	lz4-dev
	openssl-dev
	protobuf-dev
	re2-dev
	rocksdb-dev
	samurai
	snappy-dev
	sqlite-dev
	zlib-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ripple/rippled/archive/$pkgver.tar.gz
	disable-failing-test.patch
	"

prepare() {
	default_prepare

	# don't add aports gitrev into build
	git init .
}

build() {
	cmake -B build -G Ninja \
		-Dstatic=OFF \
		-Dtests="$(want_check && echo ON || echo OFF)" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release
	cmake --build build
}

check() {
	./build/rippled --unittest --unittest-jobs ${JOBS:-2}
}

package() {
	install -D -m644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
	install -D build/rippled "$pkgdir/usr/bin/rippled"
	install -D -m644 cfg/rippled-example.cfg "$pkgdir/etc/$pkgname/rippled.cfg"
	install -D -m644 cfg/validators-example.txt "$pkgdir/etc/$pkgname/validators.txt"
}

sha512sums="
4706b1c5c66941546fe54afa67d8f84cd58b5933e6953f621cd65e205d6b70a0cadaa71adaa8d0d4877bada760ca3acfe1c172246e0427cd48f847620e0ae08d  rippled-1.9.1.tar.gz
5df6abbea0252f42765d382f31194c2fa5137996adfaf8c9192a46c318f34e60d137ee690bd3baadea184d64f862040b91af169ee8dc226f67cf21e4ee60bf0a  disable-failing-test.patch
"
